package com.jrx.anytxn.investor.mapper.ext;

import com.jrx.anytxn.investor.entity.AmInterestAccrualInvestorInfo;
import com.jrx.anytxn.investor.mapper.base.AmInterestAccrualInvestorInfoMapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 累计账户mapper扩展
 *
 * @author liuyang
 * @date 2020-05-21
 **/
public interface ExtAmInterestAccrualInvestorInfoMapper extends AmInterestAccrualInvestorInfoMapper {

    /**
     * 批量插入累计账户信息
     *
     * @param amInterestAccrualInfos 累计账户信息
     * @return int 插入的条数
     * @author liuyang
     * @date 2020-05-21
     */
    int batchInsertInterestAccrualInvestorInfo(List<AmInterestAccrualInvestorInfo> amInterestAccrualInfos);

    /**
     * 根据条件查询累计账户
     *
     * @param loanId
     * @param customerId
     * @param tenantId
     * @param typeList
     * @param accountStatus
     * @return
     */
    List<AmInterestAccrualInvestorInfo> selectAllAccuAcct(String loanId, String customerId, String tenantId, List<String> typeList, String accountStatus);

    /**
     * 根据状态查询累计账户   order by id asc  计息批量使用
     *
     * @param status 状态
     * @return List<AmInterestAccrualInvestorInfo> 累计账户
     * @author liuyang
     * @date 2020-05-26
     */
    List<AmInterestAccrualInvestorInfo> selectByStatus(@Param(value = "status") String status);

    /**
     * 批量更新累计账户信息（批量可用）
     *
     * @param amInterestAccrualInfos 累计账户
     * @return int 更新的条数
     * @author liuyang
     * @date 2020-05-26
     */
    int batchUpdateInterestAccrualInfoForBatch(List<AmInterestAccrualInvestorInfo> amInterestAccrualInfos);

    /**
     * 批量更新累计账户信息（联机交易）
     *
     * @param updateAccuAcctList
     */
    void batchUpdate(List<AmInterestAccrualInvestorInfo> updateAccuAcctList);

    /**
     * 根据条件查询累计账户
     *
     * @param investorLoanId 出资方贷款id
     * @param customerId     客户id
     * @param tenantId       租户id
     * @param status         状态
     * @param billingTenor   期数
     * @return List<AmInterestAccrualInvestorInfo> 累计账户
     * @author liuyang
     * @date 2020-05-27
     */
    List<AmInterestAccrualInvestorInfo> selectAccuAcctList(@Param(value = "investorLoanId") String investorLoanId,
                                                           @Param(value = "customerId") String customerId,
                                                           @Param(value = "tenantId") String tenantId,
                                                           @Param(value = "status") String status,
                                                           @Param(value = "billingTenor") Integer billingTenor);

    /**
     * 根据出资方贷款id，账户状态查询累计未抛利息
     *
     * @param investorLoanId 出资方贷款id
     * @param accountStatus  账户状态
     * @return List<AmInterestAccrualInvestorInfo> 累计账户
     * @author liuyang
     * @date 2020-05-29
     */
    List<AmInterestAccrualInvestorInfo> selectForUpdateUncastIntr(@Param(value = "investorLoanId") String investorLoanId,
                                                                  @Param(value = "accountStatus") String accountStatus);

    /**
     * 根据出资方贷款id，账户状态查询累计未抛利息
     *
     * @param investorLoanId 出资方贷款id
     * @return List<AmInterestAccrualInvestorInfo> 累计账户
     * @author liuyang
     * @date 2020-05-29
     */
    List<AmInterestAccrualInvestorInfo> selectByInvestorLoanId(@Param("investorLoanId") String investorLoanId);

    AmInterestAccrualInvestorInfo findByAccountId(String accountId);

    /**
     * 根据条件查询累计账户
     *
     * @param investorLoanId
     * @param customerId
     * @param tenantId
     * @param type
     * @param status
     * @param stopFlag
     * @return
     */
    List<AmInterestAccrualInvestorInfo> selectAllStopAccuAcct(@Param("investorLoanId") String investorLoanId,
                                                              @Param(value = "customerId") String customerId,
                                                              @Param(value = "tenantId") String tenantId,
                                                              @Param(value = "type") String type,
                                                              @Param(value = "status") String status,
                                                              @Param(value = "stopFlag") String stopFlag);

    /**
     * 根据条件查询累计账户
     *
     * @param customerId     客户id
     * @param tenantId       租户id
     * @param statusList         状态
     * @return List<AmInterestAccrualInvestorInfo> 累计账户
     * @author liuyang
     * @date 2020-05-27
     */
    List<AmInterestAccrualInvestorInfo> findByCust(@Param(value = "customerId") String customerId,
                                                   @Param(value = "tenantId") String tenantId,
                                                   @Param("statusList") List<String> statusList);
}